home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1994 November / Cd Ware (Nro. 2) - Epimundo.iso / DOS / PG / CHART.ZIP / CFLOW1.86 < prev    next >
Encoding:
Text File  |  1993-10-25  |  16.8 KB  |  556 lines

  1.  
  2. ;All user option references are LIGHT BLUE
  3.  
  4.         ;get options available
  5.  
  6. get_options:
  7.         mov es,ax,cs    ;copy code segment
  8.         cmp b chart_flag,0    ;have chart variables been intialised?
  9.         jne >b1    ;check if getting new box if they have
  10.  
  11.         ;intialise flowchart variables
  12.  
  13.         xor ax,ax    ;load zero
  14.         mov b chart_flag,2    ;indicate getting new box data
  15.         mov w box_save,ax    ;indicate not branching
  16.         mov w key_option,ax    ;indicate not choosing a route
  17.         mov w insert_mode,ax    ;clear insert mode
  18.         mov w box_to_subchart,ax    ;indicate not choosing subchart
  19.         mov w subchart_link,ax    ;clear subchart follow box
  20.         mov w sub_stack,top_stack    ;set subchart stack pointer to top
  21.         mov b message,al    ;clear bottom line message buffer
  22.  
  23.         ;make first box in chart current box
  24.  
  25.         mov w current_box,ax    ;clear current box
  26.         mov dx,ax
  27.         mov ax,first_box
  28.         mov w next_box,ax    ;store first box number
  29.         mov bx,parent    ;clear parent element
  30.         call store_box_par    ;clear parent parameter box
  31.         xor bp,bp    ;load current box
  32.         mov b box_made,0ffh    ;set flag
  33.  
  34.         ;check if getting box data
  35.  
  36. b1:
  37.         cmp b chart_flag,2    ;is it?
  38. if ne        jmp long >b1    ;clear route string if not
  39.         test b box_made,1    ;get new box data?
  40.         je >b2    ;make new box current box if not
  41.  
  42.         ;create new box
  43.  
  44.         test b box_made,2    ;make a new box?
  45.         je >a1    ;get new box pointer if not
  46.         call make_box    ;create new box
  47.     es    mov w[di],bp    ;store it in new box
  48.         mov bx,parent    ;load offset to parent element
  49.         call get_current_box_par    ;get current box parent box
  50.     es    mov w[bx+di],ax    ;store in as new box parent
  51.         jmp >a2    ;get box descripter from user
  52.  
  53.         ;get field descripter
  54.  
  55. a1:
  56.         mov ax,w next_box    ;load new box
  57.         call get_box    ;get its pointer
  58. a2:
  59.         call writexy    ;write prompt to bottom line
  60.         db 25,24
  61.         db 'Please enter box descripter',0
  62.         mov b s,0    ;clear descripter string buffer
  63.         call get_string    ;get descripter string
  64.         dw s    ;destination buffer
  65.         db 128,0    ;maximum string length
  66.  
  67.         ;copy string to buffer
  68.  
  69.     es    mov w[di+descripter_length],cx    ;store descripter length in box
  70.     es    mov ax,w[di+descripter]    ;load address of descripter store
  71.     es    mov dx,w[di+descripter+2]
  72.         call get_pointer    ;convert it to pointer
  73.         add w start_free_memory,cx    ;move address to end of data
  74.         adc w start_free_memory+2,0
  75.         rep
  76.         movsb    ;copy string
  77.  
  78.         ;clear box child pointer
  79.  
  80.         mov ax,w next_box    ;load next box
  81.         mov bx,child    ;load element offset
  82.         xor dx,dx    ;load zero
  83.         call store_box_par    ;clear child pointer
  84.  
  85.         ;make current box new box
  86.  
  87. b2:
  88.         mov b box_made,0ffh    ;set new box flag
  89.         xor ax,ax    ;load zero
  90.         mov b new_chart,al
  91.         mov ax,w next_box    ;load next box number
  92.         mov bp,ax    ;store it as current box
  93.         inc w next_box    ;increment new box number
  94.  
  95.         ;clear route variables
  96.  
  97. b1:
  98.         mov es,ax,cs    ;copy segment to workspace
  99.         xor ax,ax    ;load zero
  100.         cmp b chart_flag,2    ;reset route variables?
  101.         jb >a1    ;check if to reset mode flag if not
  102.         mov di,o option_routes    ;load offset to extra option routes
  103.         stosw    ;clear them
  104.         stosw
  105.         stosw
  106.         stosw
  107.  
  108.         ;indicate no routes selected
  109.  
  110.         mov b route_string,al    ;clear route string
  111.         mov w current_route,ax    ;indicate no routes selected
  112. a1:
  113.         cmp b chart_flag,3    ;reset mode flag?
  114. if e        mov w insert_mode,ax    ;reset mode flag
  115.  
  116.         ;clear option variables
  117.  
  118.         call clear_options    ;clear options string
  119.         mov w first_route,yes    ;store first fixed route
  120.         call get_current_real_routes    ;get total real routes for current box
  121.  
  122.         ;check if any routes exist in current box
  123.  
  124.         cmp w key_option,0    ;is user choosing a route?
  125. if ne        jmp long >b1    ;check for route options if yes
  126.         mov b link_string,0    ;clear routes link string
  127.         mov w route_exists,0    ;indicate no existing routes
  128.         mov ax,w routes+yes    ;are there any existing routes?
  129.         or ax,w routes+no
  130. if ne        inc w route_exists    ;indicate there is a existing route
  131.  
  132.         ;set up flag indicating route(s) exists but no routes selected
  133.  
  134.         mov ax,w current_route    ;load current route
  135.         call inv_sgn    ;get inverse sign of routes flag
  136.         mul w route_exists    ;multiply it by existing routes flag
  137.         mov bx,ax    ;save flag
  138.         mov ax,w box_save    ;load occupied else flag
  139.         call inv_sgn    ;get doing nothing flag
  140.         mul bx    ;store flag indicating route(s) exists
  141.         mov w route_flag,ax    ;but not selected and nothing else doing
  142.  
  143.         ;check if occupied else, and if so whether current box is the
  144.         ;same as main box
  145.  
  146.         mov ax,w box_save    ;load main box store/flag
  147.         or ax,ax    ;is flowchart dormant?
  148.         je >b4    ;check for create/cancel option if it is
  149.         cmp ax,bp    ;is current box same as main box?
  150.         jne >a1    ;check if route selected if not
  151.         cmp ax,w subchart_link    ;is box subchart follow box?
  152.         jne >b4    ;check for create/cancel option if not
  153.         mov b flag,0ffh    ;indicate no routes point to current box
  154.             ;from main box
  155.  
  156.         ;check if there is a route selected
  157.  
  158. a1:
  159.         cmp w current_route,0    ;is there a route selected?
  160.         je >b3    ;check if copying subchart if not
  161.         cmp w box_to_subchart,0    ;is user choosing subchart?
  162.         jne >b3    ;check if on same level if yes
  163.  
  164.         ;get pointer to current box
  165.  
  166.         call get_box    ;get box pointer
  167.         mov ax,bp    ;load current box
  168.         mov bx,w current_route    ;load current route
  169.         mov cx,2    ;load other routes count
  170.  
  171.         ;check if any routes point to main box
  172.  
  173. a1:
  174.         add bx,2    ;move to next route
  175.         cmp bx,no+2    ;wrap?
  176. if e        mov bx,yes    ;load first route offset
  177.     es    cmp w[di+bx],ax    ;does route point to current box?
  178. if e        mov b flag,0    ;indicate route points to current box
  179.         loop a1    ;decrement loop count
  180.  
  181.         ;check if any routes of current box point to main box
  182.  
  183.         cmp b flag,0    ;do any routes point to current box?
  184.         je >b2    ;check for create/cancel option if yes
  185. b3:
  186.         mov dx,w routes+parent    ;save it
  187.  
  188.         ;check if current box is in same chart as main box
  189.  
  190.         mov bx,parent    ;load element
  191.         cmp w box_to_subchart,0    ;is a copied subchart being linked?
  192.         jne >a1    ;check if box is parent if it is
  193.         cmp w insert_mode,0    ;is insert mode on?
  194.         jne >a2    ;write main box to link string if it is
  195.         mov ax,w box_save    ;load main box
  196.         call get_box_par    ;get its parent box
  197.         cmp ax,dx    ;is its parent same as current box?
  198.         je >a2    ;write main box to link string if it is
  199. b4:
  200.         jmp >b2    ;check for create/cancel option
  201.  
  202.         ;check if box is parent of subchart
  203.  
  204. a1:
  205.         mov ax,w routes+child    ;load current box child pointer
  206.         or ax,ax    ;is there a child linked to current box?
  207.         je >b2    ;check for create/cancel option if not
  208.         call get_box_par    ;get parent of child of current box
  209.         cmp ax,bp    ;does it point to current box?
  210.         jne >b2    ;check for cancel/create option if not
  211.         cmp w route_exists,0    ;is there a route from box
  212.         Je >B2    ;check for create/cancel option if not
  213.  
  214.         ;flag link option available
  215.  
  216. a2:
  217.         call create_link_string    ;create link string for descripter
  218.         inc b option_array+2    ;write link option
  219.  
  220.         ;check if create or cancel option is available
  221.  
  222. b2:
  223.         mov ax,w route_flag    ;load route exists flag
  224.         add ax,w insert_mode    ;add it to mode flag
  225.         add ax,w box_save    ;add it to main box
  226.         cmp ax,w box_save    ;is create or cancel option available?
  227.         jne >a1    ;check if doing anything if not
  228.         cmp w sub_stack,top_stack    ;is stack empty?
  229.         jne >a1    ;check for branch option if not
  230.         call check_memory    ;check if sufficient memory
  231. if nc        inc b option_array+4    ;write create/cancel option
  232.  
  233.         ;check if flowchart is dormant
  234.  
  235. a1:
  236.         cmp w box_save,0    ;is it?
  237.         jne >b2    ;check for single option if not
  238.         cmp sub_stack,top_stack    ;is user viewing copied subchart?
  239. if ne        jmp long >b1    ;check route options if yes
  240.         cmp w route_flag,0    ;does route exist without any selected?
  241.         jne >a1    ;check for delete option if not
  242.         mov ax,w routes    ;load neighbour box
  243.         or ax,w route_exists    ;is there another box?
  244. if ne        inc b option_array+6    ;write branch option if there is
  245.  
  246.         ;add insert, renumber and load chart options
  247.  
  248. a1:
  249.         call check_memory    ;check if sufficient memory
  250.         jc >a1    ;don't allow inserting if out of memory
  251.         inc b option_array+10    ;add insert option to options array
  252.         cmp b chart_active,080h    ;are we in dos shell?
  253. if ne        inc b option_array+38    ;add renumber chart option if not
  254.  
  255.         ;check if delete option is available
  256.  
  257. a1:
  258.         cmp w current_route,0    ;are any routes selected?
  259.         jne >b3    ;check for insert option if they are
  260.         mov ax,w routes+child    ;load child chart
  261.         or ax,ax    ;is there a child chart?
  262.         je >a1    ;check for delete option if not
  263.         mov bx,parent    ;load parent offset
  264.         call get_box_par    ;get parent of child chart
  265.  
  266.         ;check if sub-chart is copied
  267.  
  268.         cmp ax,bp    ;is chart copied
  269.         jne >a1    ;check fixed route count if it is
  270.         cmp w real_routes,1    ;is there more than one fixed route
  271.         ja >b1    ;check for route options if there is
  272.         je >b2    ;check for single option if one route
  273.         cmp w routes,first_box    ;is box isolated?
  274.         jae >b2    ;don't delete box if not
  275.  
  276.         ;check if parent box is isolated
  277.  
  278.         mov ax,w routes+parent    ;get parent box
  279.         call get_box    ;get pointer to box
  280.     es    cmp w[di+child],bp    ;is parent box maternal?
  281.         jne >b2    ;don't allow box to be deleted if not
  282.         jmp >a2    ;flag delete option
  283. a1:
  284.         cmp w real_routes,1    ;is there more than one?
  285.         ja >b2    ;check for single option if yes
  286. a2:
  287.         inc b option_array+8    ;write delete option if not
  288.  
  289.         ;check if single option is available
  290.  
  291. b2:
  292.         cmp w current_route,0    ;is there a current route selected?
  293.         je >b1    ;check for route options if not
  294. b3:
  295.         mov ax,w insert_mode    ;load insert flag
  296.         dec ax    ;decrement it
  297.         mov bx,w box_save    ;load main box
  298.         or ax,ax    ;is flowchart dormant?
  299. if e        mov bx,ax    ;load zero
  300.         mov ax,w box_save    ;load main box
  301.         sub ax,bx    ;subtract occupied mode
  302.         sub ax,w routes+no    ;subtract decision routes flag
  303.         cmp ax,w box_save    ;is single option available?
  304. if e        inc b option_array+12    ;write single option if it is
  305.  
  306.         ;check if any of the decision route/options are available
  307.  
  308. b1:
  309.         mov b flag,0ffh    ;set flag
  310.         cmp w routes+no,0    ;is box decision box?
  311.         jne >a1    ;write route options if it is
  312.         cmp w routes+yes,0    ;is there a route?
  313.         je >a1    ;write route options if there is
  314. b2:
  315.         jmp long >b1    ;check if there is a key option if not
  316.  
  317.         ;write routes options to options string
  318.  
  319. a1:
  320.         mov b flag,0    ;clear forward flag
  321.         mov ax,w box_save    ;load main box
  322.         call sgn    ;get its sign
  323.         mov bx,ax    ;save it
  324.         mov ax,w insert_mode    ;load occupied flag
  325.         call sgn    ;get its sign
  326.         sub bx,ax    ;subtract it from main box sign
  327.         cmp bx,1    ;is current route option available?
  328. if ne        or b flag,4    ;indicate current route not available
  329.  
  330.         ;check if selecting route
  331.  
  332.         mov ax,w insert_mode    ;calculate if selecting a route for
  333.         inc ax    ;other function
  334.         mul w box_save
  335.         sub ax,w box_save
  336.         mov bx,w box_save
  337.         sub bx,ax
  338.         or bx,bx
  339.         je >a1    ;select route if option available
  340.         cmp sub_stack,top_stack    ;is stack empty?
  341. if e        or b flag,2    ;indicate choosing route for other fn
  342. a1:
  343.         xor si,si    ;load previous route
  344.         mov cx,2    ;load loop count
  345.  
  346.         ;check if route is selected route
  347.  
  348. a1:
  349.         mov w route_exists_flag,0    ;indicate route isnt linked
  350.         add si,2    ;move to next route
  351.         mov di,w[si+routes]
  352.         cmp si,w current_route    ;is route route selected?
  353.         jne >a4    ;check if route exists if not
  354.         test b flag,4    ;is current route available?
  355.         jne >a2    ;decrement loop count if not
  356.  
  357.         ;check if route exists
  358.  
  359. a4:
  360.         cmp w key_option,0    ;is user choosing a route?
  361.         jne >a4    ;check route option if yes
  362.         cmp di,1    ;is there a route?
  363.         jbe >a3    ;check route option if not
  364.         inc w route_exists_flag    ;indicate route is active
  365.         jmp >a5    ;check if there is a extra route option
  366.  
  367.         ;if key option is relinquish then check for fixed route
  368.  
  369. a4:
  370.         cmp di,1    ;is there a route?
  371.         jbe >a6    ;decrement loop count if not
  372. a3:
  373.         test b flag,2    ;choosing route for copied subchart?
  374.         je >a5    ;set route option if it is
  375.  
  376.         ;check if any extra routes
  377.  
  378. a6:
  379.         cmp w[si+option_routes],0    ;is route an extra option?
  380.         je >a2    ;decrement loop count if not
  381.  
  382.         ;write route option to options string
  383.  
  384. a5:
  385.         push si    ;save route
  386.         add si,12    ;calculate option number
  387.         mov dx,w route_exists_flag    ;load route exists flag
  388.         add w option_array,dx    ;add it to total routes count
  389.         inc dx    ;adjust it
  390.         mov w[si+option_array],dx    ;write route option
  391.         pull si    ;restore route
  392.  
  393.         ;decrement loop count
  394.  
  395. a2:
  396.         loop a1    ;decrement loop count
  397.  
  398.         ;check if there is a key option
  399.  
  400. b1:
  401.         mov si,w key_option    ;load flag
  402.         or si,si    ;is user choosing a route?
  403.         je >a1    ;check previous option if not
  404.         inc b[si+option_array]    ;write it to option string
  405.         jmp long >b1    ;set current route
  406.  
  407.         ;check if previous option is available
  408.  
  409. a1:
  410.         cmp w routes,0    ;is there a neighbour box?
  411.         je >a1    ;check for subchart option if nom
  412.         cmp w insert_mode,0    ;is flowchart dormant?
  413. if e        inc b option_array+18    ;write previous option if it is
  414.  
  415.         ;check if subchart exists and if it can be selected
  416.  
  417. a1:
  418.         mov dx,w box_save    ;load occupied flag
  419.         cmp w subchart_link,0    ;is user choosing a subchart?
  420.         jne >a2    ;check if subchart exists if yes
  421.         or dx,dx    ;is flowchart dormant?
  422.         jne >b4    ;check for end subchart option if not
  423. a2:
  424.         mov ax,w routes+child    ;load child chart
  425.         cmp ax,first_box    ;is there a existing subchart?
  426.         jb >a4    ;check for up option if not
  427.  
  428.         ;check if subchart is step child and if stack is full
  429.  
  430.         mov bx,parent    ;load parent offset
  431.         call get_box_par    ;get parent of child
  432.         cmp ax,bp    ;is it a step child chart?
  433.         je >a1    ;add option if it is
  434.         cmp w sub_stack,o bottom_stack    ;is stack full?
  435.         je >a4    ;check up option if it is
  436. a1:
  437.         inc b option_array+22    ;write down option
  438.         jmp >a5    ;check for up option
  439.  
  440.         ;check if subchart option is available
  441.  
  442. a4:
  443.         or dx,dx    ;can a subchart be created?
  444.         jne >a3    ;check for up option if not
  445.         cmp w sub_stack,top_stack    ;is stack empty?
  446.         jne >a1    ;check for parent box if not
  447.         call check_memory    ;check if sufficient memory
  448.         jc >a5    ;don't allow subcharts or loading if not
  449.         inc b option_array+20    ;write create subchart option
  450.         cmp b chart_active,080h    ;is chart in interrupt?
  451. if ne        inc b option_array+40    ;add load chart option
  452.  
  453.         ;check if up option is available
  454.  
  455. a5:
  456.         or dx,dx    ;is flowchart dormant?
  457.         je >a1    ;check if on subchart level if it is
  458. a3:
  459.         cmp w box_to_subchart,0    ;is user choosing a subchart?
  460.         jne >a1    ;check if parent of box if not
  461.  
  462.         ;write view function to options
  463.  
  464. b4:
  465.         inc b option_array+32    ;write view main box option
  466. b5:
  467.         jmp long >b3    ;add goto box option
  468. a1:
  469.         cmp w routes+parent,0    ;is is there a parent chart?
  470. if ne        inc b option_array+24    ;write up option if there is
  471.  
  472.         ;check if flowchart is dormant
  473.  
  474.         or dx,dx    ;is it?
  475.         jne b4    ;add view box function if not
  476.         cmp w sub_stack,top_stack    ;is user viewing a copied subchart?
  477.         jne b5    ;check for goto option if yes
  478.         cmp w current_route,0    ;are any routes selected?
  479.         jne >b2    ;check for end subchart option if yes
  480.  
  481.         ;check for any branched routes
  482.  
  483.         mov w branch_route_count,0    ;clear count
  484.         mov si,no    ;load no route
  485.  
  486.         ;check if there is a route
  487.  
  488. a1:
  489.         mov w[si+option_routes],0    ;clear extra route option
  490.         mov bx,si    ;load route offset
  491.         call get_current_box_par    ;get route parameter
  492.         cmp ax,1    ;is there one?
  493.         jbe >a2    ;move to next route if not
  494.         cmp ax,bp    ;is route outstanding route?
  495.         je >a2    ;don't count this route if it is
  496.  
  497.         ;check if route is branch
  498.  
  499.         inc w branch_route_count    ;increment count
  500.         mov w[si+option_routes],1    ;add extra route option
  501.         mov w first_branch_route,si    ;store first branch route
  502. a2:
  503.         sub si,2    ;move to next route
  504.         jne a1    ;decrement loop count
  505.         cmp w branch_route_count,0    ;are there any branches from box?
  506. if ne        inc b option_array+26    ;write relinquish branch option
  507.  
  508.         ;check if end subchart option is available
  509.  
  510. b2:
  511.         mov ax,w route_flag    ;load route exists but not selected flag
  512.         add ax,w insert_mode    ;add it to occupied flag
  513.         or ax,ax    ;is anything else going on?
  514.         jne >a1    ;check insert subchart option if yes
  515.         cmp w routes+parent,0    ;is this a subchart?
  516. if ne        inc b option_array+28    ;write end subchart option if it is
  517.  
  518.         ;check if select subchart option is available
  519.  
  520. a1:
  521.         cmp w box_to_subchart,0    ;can a subchart be selected?
  522.         jne >a1    ;check if flowchart is dormant if not
  523.         call check_memory    ;check if sufficient memory
  524. if nc        inc b option_array+30    ;write copy subchart option
  525.         inc b option_array+42    ;add xchange box function option
  526. a1:
  527.         cmp w box_save,0    ;is flowchart dormant?
  528. if e        inc b option_array+36    ;add ammend descripter option if it is
  529.  
  530.         ;check if 'goto box' option is available
  531.  
  532. b3:
  533.         cmp w insert_mode,0    ;is flowchart dormant?
  534.         jne >a1    ;check ammend option if not
  535.         inc b option_array+34    ;write goto box option
  536.         inc b option_array+44    ;write search option
  537.  
  538.         ;check if forward option is available
  539.  
  540. b1:
  541.         cmp w insert_mode,0    ;is flowchart dormant?
  542.         jne >a1    ;set route select if not
  543.         test b flag,1    ;are there any other route options?
  544. if ne        inc b option_array+46    ;add forward option
  545.  
  546.         ;initialise selected route variable
  547.  
  548. a1:
  549.         mov ax,w current_route    ;load route select
  550.         mov w route,ax    ;store it
  551.         or ax,ax    ;is route single?
  552. if e        add w route,2    ;make route select simple box route
  553.         ret    ;exit
  554.  
  555.         ;end
  556.